﻿/* ==============================================================================
 * 功能描述：GoodsProvider  
 * 
 * 创 建 者：郑镇泉
 * 
 * 创建日期：2016/4/15 22:31:43
 * ==============================================================================*/
using UnityEngine;
using System.Collections;

public class GoodsConfigProvider : BaseProvider<GoodsConfigProvider>
{
    private GoodsConfig goodsConfig;

    public GoodsConfig GoodsConfig
    {
        get
        {
            if (goodsConfig == null)
            {
                goodsConfig = LoadConfig<GoodsConfig>("/xml/GoodsConfig.xml");
            }
            return goodsConfig;
        }
    }

    public GoodsConfigGoods[] GetAll()
    {
        return GoodsConfig.Items;
    }

    public GoodsConfigGoods GetGoodsById(int id)
    {
        GoodsConfigGoods goods = System.Array.Find<GoodsConfigGoods>(GoodsConfig.Items, (GoodsConfigGoods obj) =>
        {
            return int.Parse(obj.id) == id;
        });
        if (goods == null) Debug.Log("配置表中找不到该物品，id：" + id);
        Debug.Log(string.Format("物品id:{0},物品名称：{1},物品图标：{2}，物品描述：{3}",goods.id,goods.name,goods.icon,goods.des));
        return goods;
    }
}